package com.ecas.core.base.dao.aop;

import com.ecas.core.annotation.Cached;
import com.ecas.core.annotation.Type;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import sun.misc.Cache;

import java.lang.annotation.Annotation;
import java.util.Arrays;

/**
 * @author dewen.ye
 * @date 2019/1/27 19:21
 */
@Component
@Aspect
public class CacheAspectj {


    private Cache cache;

    public CacheAspectj() {

    }

    @Pointcut(value = "execution( public * com.ecas.dao..*(..))")
    public void pointCut() {

    }

    //TODO  think key and value design
    @Around("pointCut()")
    public void cacheAround(ProceedingJoinPoint joinPoint) {
        String methodMame = joinPoint.getSignature().getName();
        Object[] args = joinPoint.getArgs();
        Cached annotation = (Cached) joinPoint.getSignature().getDeclaringType().getAnnotation(Cached.class);
        if (annotation != null) {
            if (Type.SAVE.equals(annotation.type())) {

            } else if (Type.MODIFY.equals(annotation.type())) {

            } else {

            }
        }


    }
}
